from typing import List


def decode_ways(nums: List[int]) -> int:
    if not nums:
        return 0
    dp = []
    dp.append(1)
    if nums[0] != 0:
        dp.append(1)
    else:
        dp.append(0)
    for i in range(1, len(nums)):
        cur = nums[i]
        pre = nums[i - 1]
        val = 0
        if 1 <= pre <= 2 and 0 <= cur <= 6:
            val += dp[-2]
        if 1 <= cur <= 9:
            val += dp[-1]
        dp.append(val)

    return dp[-1]
